package com.summit.exam.servlet;


import com.summit.exam.dbdao.ScoreInfoDao;
import com.summit.exam.entity.ScoreInfoBean;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

public class lookScoreServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //查看所有考试
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");

        //查询所有考生的考试信息
        String username = (String)req.getSession().getAttribute("username");


        //查询该用户信息
        ScoreInfoDao scoreService = new ScoreInfoDao();
        ArrayList<ScoreInfoBean> infoArrayList = scoreService.selectInfo(username);

        if (infoArrayList != null){
            System.out.println(infoArrayList.toString());
            req.setAttribute("infoArrayList", infoArrayList);
        }else {
            System.out.println("数据为空");
            System.out.println(infoArrayList.toString());
        }

        req.getRequestDispatcher( "/ExamSystem/techweb/StudentScore.jsp").forward(req, resp);
    }
}
